/**
 * Created by HZH
 * Date-Time: 2022-01-26
 */

import React from 'react';
import ProTable from '@ant-design/pro-table';
// import styles from './index.less';

const searchConf = {
  labelWidth: 120,
  defaultCollapsed: false,
  // collapseRender: () => null,
};

const optionsConf = {
  fullScreen: true,
  reload: true,
  setting: true,
  density: false,
};

const paginationConf = {
  defaultPageSize: 20,
  pageSizeOptions: ['10', '20', '30', '50'],
  showQuickJumper: true,
};

export default (props) => {
  const {
    headerTitle = '',
    rowKey = 'id',
    search,
    options,
    pagination,
    tableAlertRender = false,
    ...config
  } = props;

  return (
    <ProTable
      headerTitle={headerTitle}
      rowKey={rowKey}
      search={ search === false ? search : { ...searchConf, ...search }}
      options={{ ...optionsConf, ...options }}
      pagination={{ ...paginationConf, ...pagination }}
      tableAlertRender={tableAlertRender}
      {...config}
    />
  );
};
